package entitys;
 
import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author Amauri
 */
@Entity
@Table(name = "team")
public class Time implements Serializable{
    
    @SequenceGenerator(
            allocationSize = 1, 
            schema = "myschema",  
            name = "CD_TIME_GENERATOR", 
            sequenceName = "PESSOA_SEQ"
    )
    @Id
    @GeneratedValue(
            strategy = GenerationType.SEQUENCE, 
            generator = "CD_TIME_GENERATOR"
    )
    private Long id;
    private String nome;
    
    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List<Usuario> players;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return nome;
    }

    public void setName(String nome) {
        this.nome = nome;
    }

    public List<Usuario> getPlayers() {
        return players;
    }

    public void setPlayers(List<Usuario> usuarios) {
        this.players = usuarios;
    }
    
    @Override
    public boolean equals(Object obj){
        if(this.id == ((Time)obj).id){
            return true;
        }else{
            return false;
        }
    }
}